using AlipayClass;
using ASP;
using HoWave.Common;
using HoWave.Web;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class User_Alipay_return_url : Page, IRequiresSessionState
{
	protected Label lbTrade_no;
	protected Label lbOut_trade_no;
	protected Label lbTotal_fee;
	protected Label lbSubject;
	protected Label lbBody;
	protected Label lbBuyer_email;
	protected Label lbTrade_status;
	protected Label lbVerify;
	protected HtmlForm form1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		SortedDictionary<string, string> requestGet = this.GetRequestGet();
		AlipayConfig alipayConfig = new AlipayConfig();
		string partner = alipayConfig.Partner;
		string key = alipayConfig.Key;
		string input_charset = alipayConfig.Input_charset;
		string sign_type = alipayConfig.Sign_type;
		string transport = alipayConfig.Transport;
		if (requestGet.Count > 0)
		{
			AlipayNotify alipayNotify = new AlipayNotify(requestGet, base.Request.QueryString["notify_id"], partner, key, input_charset, sign_type, transport);
			string responseTxt = alipayNotify.ResponseTxt;
			string text = base.Request.QueryString["sign"];
			string mysign = alipayNotify.Mysign;
			base.Response.Write("responseTxt：" + responseTxt + "<br/>");
			base.Response.Write("sign：" + text + "<br/>");
			base.Response.Write("mysign：" + mysign + "<br/>");
			if (responseTxt == "true" || text == mysign)
			{
				string text2 = base.Request.QueryString["trade_no"];
				string text3 = base.Request.QueryString["out_trade_no"];
				string text4 = base.Request.QueryString["total_fee"];
				string text5 = base.Request.QueryString["subject"];
				string text6 = base.Request.QueryString["body"];
				string text7 = base.Request.QueryString["buyer_email"];
				string text8 = base.Request.QueryString["trade_status"];
				base.Response.Write("trade_no：" + base.Request.QueryString["trade_no"] + "<br/>");
				base.Response.Write("order_no：" + base.Request.QueryString["out_trade_no"] + "<br/>");
				base.Response.Write("total_fee：" + base.Request.QueryString["total_fee"] + "<br/>");
				base.Response.Write("subject：" + base.Request.QueryString["subject"] + "<br/>");
				base.Response.Write("body：" + base.Request.QueryString["body"] + "<br/>");
				base.Response.Write("buyer_email：" + base.Request.QueryString["buyer_email"] + "<br/>");
				base.Response.Write("trade_status：" + base.Request.QueryString["trade_status"] + "<br/>");
				base.Response.Write("sign：" + base.Request.QueryString["sign"] + "<br/>");
				this.lbTrade_no.Text = text2;
				this.lbOut_trade_no.Text = text3;
				this.lbTotal_fee.Text = text4;
				this.lbSubject.Text = text5;
				this.lbBody.Text = text6;
				this.lbBuyer_email.Text = text7;
				this.lbTrade_status.Text = text8;
				this.lbVerify.Text = "验证成功";
				Conn conn = new Conn();
				OrderAction orderAction = new OrderAction(conn);
				if (base.Request.QueryString["trade_status"] == "TRADE_FINISHED" || base.Request.QueryString["trade_status"] == "TRADE_SUCCESS")
				{
					orderAction.PayReturn(text3, "Pay");
				}
				else
				{
					base.Response.Write("trade_status=" + base.Request.QueryString["trade_status"]);
				}
			}
			else
			{
				this.lbVerify.Text = "验证失败";
			}
		}
		else
		{
			this.lbVerify.Text = "无返回参数";
		}
	}
	public SortedDictionary<string, string> GetRequestGet()
	{
		SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
		NameValueCollection queryString = base.Request.QueryString;
		string[] allKeys = queryString.AllKeys;
		for (int i = 0; i < allKeys.Length; i++)
		{
			sortedDictionary.Add(allKeys[i], base.Request.QueryString[allKeys[i]]);
		}
		return sortedDictionary;
	}
}
